package com.bondar.task2;

public class Consumer<T> implements Runnable{
	private Buffer<T> buffer;
	
	public Consumer(Buffer<T> buffer) {
		this.buffer = buffer;
	}

	@Override
	public void run() {
		int i = 0;
		String threadName = Thread.currentThread().getName();

		while (i < buffer.size()) {
			try {
				i++;
//				System.out.println(String.format("%s: try to get", threadName));
				System.out.println(String.format("%s: getted %s", threadName, buffer.get()));
//				System.out.println(String.format("!!!!!%s end operation!!!!!", threadName));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
